package cn.liyunqi.ttv.main.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil extends cn.liyunqi.core.util.StringUtil {

    /**
     * 空格换行去除
     * @param str
     * @return
     */
    public static String replaceBlank(String str) {
        String dest = "";
        if (str!=null) {
            Pattern p = Pattern.compile("\\s*|\t|\r|\n");
            Matcher m = p.matcher(str);
            dest = m.replaceAll("");
        }
        return dest;

    }

    public static String checkString(String writetemp,String without){
        return writetemp.replaceAll(without,"");
    }

    public static String checkFirstString(String temp,String without){
        if(temp.startsWith(without)){
            int del = temp.indexOf(without);
            if(temp.length() > 1){
                temp = temp.substring(del + 1);
            }else{
                temp = "";
            }
        }
        return temp;
    }

    public static boolean isNullOrEmpty(Object obj){
        if(obj == null)return true;
        return obj.toString().trim().isEmpty();
    }
}
